/**
* 左边菜单
*/ 
<template>
  <el-menu
    :collapse="collapsed"
    collapse-transition
    router
    :default-active="$route.path"
    unique-opened
    class="el-menu-vertical-demo"
    background-color="#334157"
    text-color="#fff"
    active-text-color="#ffd04b"
  >
    <div class="logobox">
      <img class="logoimg" src="../assets/img/logo.png" alt="" />
    </div>
    <el-submenu
      v-for="menu in allmenu"
      :key="menu.menuid"
      :index="menu.menuname"
    >
      <template slot="title">
        <i class="iconfont" :class="menu.icon"></i>
        <span>{{ menu.menuname }}</span>
      </template>
      <el-menu-item-group>
        <el-menu-item
          v-for="chmenu in menu.menus"
          :index="'/' + chmenu.url"
          :key="chmenu.menuid"
        >
          <i class="iconfont" :class="chmenu.icon"></i>
          <span>{{ chmenu.menuname }}</span>
        </el-menu-item>
      </el-menu-item-group>
    </el-submenu>
  </el-menu>
</template>
<script>
import { menu } from "../api/userMG";
export default {
  name: "leftnav",
  data() {
    return {
      collapsed: false,
      allmenu: [],
    };
  },
  // 创建完毕状态(里面是操作)
  created() {
    // 获取图形验证码
    let res = {
      success: true,
      data: [
        {
          menuid: 10,
          icon: "icon-gaikuang",
          menuname: "经营概况",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 11,
              icon: "icon-gaikuang",
              menuname: "经营概况",
              hasThird: "N",
              url: "operationsummary/Operations",
              menus: null,
            },
          ],
        },
        {
          menuid: 20,
          icon: "icon-gongzuotai",
          menuname: "工作台",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 21,
              icon: "icon-gongzuotai",
              menuname: "工作台",
              hasThird: "N",
              url: "workbench/workbench",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 30,
        //   icon: "icon-xinjian",
        //   menuname: "新开就诊",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 31,
        //       icon: "icon-xinjian",
        //       menuname: "新开就诊",
        //       hasThird: "N",
        //       url: "workbench/card",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 40,
          icon: "icon-guahao",
          menuname: "挂号管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 41,
              icon: "icon-guahaoregister",
              menuname: "新增挂号",
              hasThird: "N",
              url: "register/registercreate",
              menus: null,
            },
            {
              menuid: 42,
              icon: "icon-order",
              menuname: "挂号记录",
              hasThird: "N",
              url: "register/registerhistory",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 50,
        //   icon: "icon-yaopin",
        //   menuname: "药品零售",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 51,
        //       icon: "icon-zhongxiyaopin",
        //       menuname: "药品零售",
        //       hasThird: "N",
        //       url: "machine/MachineConfig",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 60,
          icon: "icon-shoufei",
          menuname: "收费管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 61,
              icon: "icon-shoufei",
              menuname: "收费管理",
              hasThird: "N",
              url: "charge/chargeManagement",
              menus: null,
            },
          ],
        },
        {
          menuid: 70,
          icon: "icon-wodehuanzhe",
          menuname: "患者管理",
          hasThird: null,
          url: null,
          menus: [
            // {
            //   menuid: 71,
            //   icon: "icon-wodehuanzhe",
            //   menuname: "患者管理",
            //   hasThird: "N",
            //   url: "pay/Config",
            //   menus: null,
            // },
            {
              menuid: 72,
              icon: "icon-wodehuanzhe",
              menuname: "患者查询",
              hasThird: "N",
              url: "patient/PatientSelect",
              menus: null,
            },
            // {
            //   menuid: 73,
            //   icon: "icon-wodehuanzhe",
            //   menuname: "地址测试",
            //   hasThird: "N",
            //   url: "patient/Address",
            //   menus: null,
            // }
          ],
        },
        {
          menuid: 80,
          icon: "icon-yaopin1",
          menuname: "药品管理",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 81,
              icon: "icon-mazuiyaopin",
              menuname: "药品信息维护",
              hasThird: "N",
              url: "medicine/info",
              menus: null,
            },
            {
              menuid: 82,
              icon: "icon-kucun",
              menuname: "库存管理",
              hasThird: "N",
              url: "medicine/stock",
              menus: null,
            },
            {
              menuid: 83,
              icon: "icon-tiaojiaadjust",
              menuname: "药品调价",
              hasThird: "N",
              url: "medicine/price",
              menus: null,
            },
          ],
        },
        // {
        //   menuid: 90,
        //   icon: "icon-huiyuan",
        //   menuname: "会员管理",
        //   hasThird: null,
        //   url: null,
        //   menus: [
        //     {
        //       menuid: 91,
        //       icon: "icon-huiyuan",
        //       menuname: "会员管理",
        //       hasThird: "N",
        //       url: "pay/Config",
        //       menus: null,
        //     },
        //   ],
        // },
        {
          menuid: 100,
          icon: "icon-tongji",
          menuname: "统计报表",
          hasThird: null,
          url: null,
          menus: [
            {
              menuid: 101,
              icon: "icon-yinjinshoufei",
              menuname: "收费统计",
              hasThird: "N",
              url: "statisticalreport/ChargeStatistics",
              menus: null,
            },
            {
              menuid: 102,
              icon: "icon-huanzhepatient",
              menuname: "患者统计",
              hasThird: "N",
              url: "patient/PatientMain",
              menus: null,
            },
            // {
            //   menuid: 103,
            //   icon: "icon-ct",
            //   menuname: "检查项目统计",
            //   hasThird: "N",
            //   url: "system/Permission",
            //   menus: null,
            // },
            // {
            //   menuid: 104,
            //   icon: "icon-zu",
            //   menuname: "药品统计",
            //   hasThird: "N",
            //   url: "system/Dept",
            //   menus: null,
            // },
          ],
        },
        {
          menuid: 110,
          icon: "icon-iconset",
          menuname: "系统设置",
          hasThird: null,
          url: null,
          menus: [
            // {
            //   menuid: 111,
            //   icon: "icon-yiyuan2",
            //   menuname: "诊所信息维护",
            //   hasThird: "N",
            //   url: "system/Dept",
            //   menus: null,
            // },
            // {
            //   menuid: 112,
            //   icon: "icon-tubiaozhizuomoban-27",
            //   menuname: "字典表维护",
            //   hasThird: "N",
            //   url: "system/Variable",
            //   menus: null,
            // },
            {
              menuid: 113,
              icon: "icon-yuangongzhanghaoguanli",
              menuname: "员工管理",
              hasThird: "N",
              url: "system/employeemain",
              menus: null,
            },
            // {
            //   menuid: 114,
            //   icon: "icon-hecigongzhenjiancha",
            //   menuname: "检查项目设置",
            //   hasThird: "N",
            //   url: "system/employeemain",
            //   menus: null,
            // },
            // {
            //   menuid: 115,
            //   icon: "icon-gongyingshangguanli",
            //   menuname: "供应商管理",
            //   hasThird: "N",
            //   url: "system/Dept",
            //   menus: null,
            // },
            // {
            //   menuid: 116,
            //   icon: "icon-moban",
            //   menuname: "模板维护",
            //   hasThird: "N",
            //   url: "system/Dept",
            //   menus: null,
            // },
            {
              menuid: 117,
              icon: "icon-feiyongguanli",
              menuname: "费用设置",
              hasThird: "N",
              url: "system/chargemain",
              menus: null,
              
            },
            // {
            //   menuid: 118,
            //   icon: "icon-jichupeizhi",
            //   menuname: "基础设置",
            //   hasThird: "N",
            //   url: "system/Dept",
            //   menus: null,
            // },
          
          ],
        },
      ],
      msg: "success",
    };
    this.allmenu = res.data;

    // menu(localStorage.getItem('logintoken'))
    //   .then(res => {
    //     console.log(JSON.stringify(res))
    //     if (res.success) {
    //       this.allmenu = res.data
    //     } else {
    //       this.$message.error(res.msg)
    //       return false
    //     }
    //   })
    //   .catch(err => {
    //     this.$message.error('菜单加载失败，请稍后再试！')
    //   })
    // 监听
    this.$root.Bus.$on("toggle", (value) => {
      this.collapsed = !value;
    });
  },
};
</script>
<style>
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 240px;
  min-height: 400px;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  border: none;
  text-align: left;
}
.el-menu-item-group__title {
  padding: 0px;
}
.el-menu-bg {
  background-color: #1f2d3d !important;
}
.el-menu {
  border: none;
}
.logobox {
  height: 40px;
  line-height: 40px;
  color: #9d9d9d;
  font-size: 20px;
  text-align: center;
  padding: 20px 0px;
}
.logoimg {
  height: 40px;
}
</style>